// Vita3K emulator project
// Copyright (C) 2024 Vita3K team
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#pragma once

#include <mem/ptr.h>

enum SceJpegEncErrorCode : uint32_t {
    SCE_JPEGENC_ERROR_IMAGE_SIZE = 0x80650200,
    SCE_JPEGENC_ERROR_INSUFFICIENT_BUFFER = 0x80650201,
    SCE_JPEGENC_ERROR_INVALID_COMPRATIO = 0x80650202,
    SCE_JPEGENC_ERROR_INVALID_PIXELFORMAT = 0x80650203,
    SCE_JPEGENC_ERROR_INVALID_HEADER_MODE = 0x80650204,
    SCE_JPEGENC_ERROR_INVALID_POINTER = 0x80650205,
    SCE_JPEGENC_ERROR_NOT_PHY_CONTINUOUS_MEMORY = 0x80650206
};

enum SceJpegEncoderPixelFormat : int32_t {
    SCE_JPEGENC_PIXEL_RGBA8888 = 0,
    SCE_JPEGENC_PIXEL_BGRA8888 = 4,
    SCE_JPEGENC_PIXEL_YCBCR420 = 8,
    SCE_JPEGENC_PIXEL_YCBCR422 = 9,
    SCE_JPEGENC_PITCH_HW_CSC = 16,
};

enum SceJpegEncoderHeaderMode : int32_t {
    SCE_JPEGENC_HEADER_MODE_JPEG = 0,
    SCE_JPEGENC_HEADER_MODE_MJPEG = 1
};

enum SceJpegEncoderInitParamOption : int32_t {
    SCE_JPEGENC_INIT_PARAM_OPTION_NONE = 0,
    SCE_JPEGENC_INIT_PARAM_OPTION_LPDDR2_MEMORY = 1
};

struct SceJpegEncoderInitParam {
    uint32_t size;
    int32_t inWidth;
    int32_t inHeight;
    int32_t pixelFormat;
    Ptr<uint8_t> outBuffer;
    uint32_t outSize;
    SceJpegEncoderInitParamOption option;
};

enum SceJpegError {
    SCE_JPEG_ERROR_IMAGE_EMPTY = 0x80650003,
    SCE_JPEG_ERROR_BAD_MARKER_LENGTH = 0x80650004,
    SCE_JPEG_ERROR_BAD_DHT_COUNTS = 0x80650005,
    SCE_JPEG_ERROR_BAD_DHT_INDEX = 0x80650006,
    SCE_JPEG_ERROR_BAD_DQT_INDEX = 0x80650007,
    SCE_JPEG_ERROR_DECODE_ERROR = 0x80650009,
    SCE_JPEG_ERROR_INVALID_POINTER = 0x80650010,
    SCE_JPEG_ERROR_BAD_COMPONENT_ID = 0x80650011,
    SCE_JPEG_ERROR_UNSUPPORT_COLORSPACE = 0x80650013,
    SCE_JPEG_ERROR_BAD_MCU_SIZE = 0x80650014,
    SCE_JPEG_ERROR_BAD_PRECISION = 0x80650015,
    SCE_JPEG_ERROR_UNSUPPORT_SAMPLING = 0x80650016,
    SCE_JPEG_ERROR_COMPONENT_COUNT = 0x80650017,
    SCE_JPEG_ERROR_CONVERSION_NOTIMPL = 0x80650018,
    SCE_JPEG_ERROR_EOI_EXPECTED = 0x80650019,
    SCE_JPEG_ERROR_UNSUPPORT_IMAGE_SIZE = 0x80650020,
    SCE_JPEG_ERROR_NO_HUFF_TABLE = 0x80650021,
    SCE_JPEG_ERROR_NO_QUANT_TABLE = 0x80650022,
    SCE_JPEG_ERROR_NO_SOI = 0x80650023,
    SCE_JPEG_ERROR_BAD_DQT_MARKER = 0x80650024,
    SCE_JPEG_ERROR_BAD_DHT_MARKER = 0x80650025,
    SCE_JPEG_ERROR_BAD_DRI_MARKER = 0x80650026,
    SCE_JPEG_ERROR_BAD_SOF_MARKER = 0x80650027,
    SCE_JPEG_ERROR_BAD_SOS_MARKER = 0x80650028,
    SCE_JPEG_ERROR_SOF_DUPLICATE = 0x80650029,
    SCE_JPEG_ERROR_NO_LOSSLESS_SUPPORT = 0x80650031,
    SCE_JPEG_ERROR_NO_ARITH_SUPPORT = 0x80650032,
    SCE_JPEG_ERROR_UNKNOWN_MARKER = 0x80650035,
    SCE_JPEG_ERROR_BAD_RESTART_MARKER = 0x80650036,
    SCE_JPEG_ERROR_UNEXPECTED_MARKER = 0x80650037,
    SCE_JPEG_ERROR_INVALID_REGION = 0x80650038,
    SCE_JPEG_ERROR_INVALID_STATE = 0x80650039,
    SCE_JPEG_ERROR_CANNOT_CONTINUE = 0x80650040,
    SCE_JPEG_ERROR_OUT_OF_MEMORY = 0x80650041,
    SCE_JPEG_ERROR_CANNOT_INIT = 0x80650042,
    SCE_JPEG_ERROR_CANNOT_FINISH = 0x80650043,
    SCE_JPEG_ERROR_INVALID_COLOR_FORMAT = 0x80650050,
    SCE_JPEG_ERROR_NOT_PHY_CONTINUOUS_MEMORY = 0x80650053,
    SCE_JPEG_ERROR_UNSUPPORT_DOWNSCALE = 0x80650060,
    SCE_JPEG_ERROR_BAD_PROGRESSIVE_PARAM = 0x80650061,
    SCE_JPEG_ERROR_EXCEED_MAX_SPLIT_DECODER = 0x80650062,
    SCE_JPEG_ERROR_INIT_DONE = 0x80650063,
    SCE_JPEG_ERROR_INPUT_SUSPENDED = 0x80650064,
    SCE_JPEG_ERROR_INPUT_DATA_TOO_BIG = 0x80650065,
    SCE_JPEG_ERROR_INVALID_DATA_SIZE = 0x80650066,
};
